/*
 * 
 * Raj Akula	
 * Inventory Look Up Android Application
 * CSC 594
 * 
 * DatabaseHelper
 * Creates Database and initlizes it..  
 * 
 */



package nku.csc594.project3;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase;

public class DatabaseHelper extends SQLiteOpenHelper {
	private static final String DATABASE_NAME="db";
	static final String TITLE="title";
	static final String VALUE="value";
	
	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, 1);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) 
	{
		db.execSQL("CREATE TABLE items (_id INTEGER PRIMARY KEY AUTOINCREMENT, category TEXT, itemnumber TEXT, qoh INTEGER, price REAL, pict INTEGER);");
		
		ContentValues cv = new ContentValues();
		cv.put("category", "CPU");
		cv.put("itemnumber", "INT12345");
		cv.put("qoh", 23);
		cv.put("price", 99.99);
		cv.put("pict", 0);
		db.insert("items","category",cv);
		
		cv.put("category", "CPU");
		cv.put("itemnumber", "AMD12345");
		cv.put("qoh", 6);
		cv.put("price", 59.99);
		cv.put("pict", 0);
		db.insert("items","category",cv);
		
		cv.put("category", "Case");
		cv.put("itemnumber", "TTA23456");
		cv.put("qoh", 4);
		cv.put("price", 99.99);
		cv.put("pict", 0);
		db.insert("items","category",cv);
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 
	{
		android.util.Log.w("Constants", "Upgrading database, which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS constants");
		onCreate(db);
	}
	
}